import type { RuleObject } from 'ant-design-vue/lib/form';

export const formRules = (props: {
  name: string;
  mes: string;
  validFunc?: any;
  min?: number;
  max?: number;
}) => {
  const { name, mes, validFunc, min, max } = props;
  const rulesArr = [
    { required: true, message: mes, trigger: 'blur' },
    { min: min, max: max, message: `请输入${min}~${max}的${name}` },
    { validator: validFunc },
  ];
  return rulesArr as RuleObject | RuleObject[] | undefined;
};

export const simpleFormRules = (name: string, mes: string) => {
  const rulesArr = [{ required: true, message: mes, trigger: 'change' }];
  return rulesArr as RuleObject | RuleObject[] | undefined;
};
